home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / ISSUE02 / TPACK / TPACK.ZIP / DEMOPACK.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-06-02  |  9.7 KB  |  373 lines

  1. {------------------------------------------------------------------------------}
  2. {UNREGISTERED VERSION (6/1/95) PLEASE REDISTRIBUTE IN tPACK.ZIP!
  3.  This revision does not contain everything, nor are the exciting
  4.  DataSetReporter and ExtendedMenu[Item] components included.
  5.  Use SWREG#5906 to receive these, icons and a help file for $130.
  6.  You must register when using this code in a business application!
  7.  You'll receive a license to use this code in up to 50 copies of
  8.  any app you write. In turn you will get responsive e-mail
  9.  tech support and enhancements till I run out of registrations
  10.  or suggestions. Meanwhile.. enjoy the code. Bye! I'll make more.
  11.  {(C)'1995 Michael/Ax-Systems, 71560,1754@Compuserve.com}
  12. {------------------------------------------------------------------------------}
  13.  
  14. unit DemoPack;
  15.  
  16. interface
  17.  
  18. uses
  19.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  20.   Forms, Dialogs, Grids, StdCtrls, Buttons, ExtCtrls, TabNotBk
  21.   , UserInfo
  22.   , UserNetw
  23.   , UserBDE
  24.   , UserWin
  25.   , Splash
  26.   , Bitbox
  27.   , Resizer
  28.   , Shells
  29.   , Restorer
  30.   , Debugctl
  31.   , ErrorMsg
  32.   , OkCore
  33.   , Working
  34.   , LoginDlg
  35.   , IniLink
  36.   , Toolbar
  37.   , MiscComp
  38.   , Invoice
  39.   , TpAbout
  40.   , ToolProc
  41.   , DocProps, About;
  42.  
  43. type
  44.   TtPack2Form = class(TDemoForm)
  45.     TabbedNotebook1: TTabbedNotebook;
  46.     WindowsGrid: TStringGrid;
  47.     NovellGrid: TStringGrid;
  48.     BDEGrid: TStringGrid;
  49.     Memo1: TMemo;
  50.     Button1: TButton;
  51.     Label1: TLabel;
  52.     Label2: TLabel;
  53.     Label3: TLabel;
  54.     Edit1: TEdit;
  55.     Label4: TLabel;
  56.     Button2: TButton;
  57.     Panel1: TPanel;
  58.     SpeedButton1: TSpeedButton;
  59.     Edit2: TEdit;
  60.     Label5: TLabel;
  61.     Label6: TLabel;
  62.     Edit3: TEdit;
  63.     Button3: TButton;
  64.     Label7: TLabel;
  65.     Edit4: TEdit;
  66.     Button4: TButton;
  67.     Label8: TLabel;
  68.     StatusBar2: TStatusBar;
  69.     MessagePanel1: TMessagePanel;
  70.     StatusPanel1: TStatusPanel;
  71.     WindowsUserInfo1: TWindowsUserInfo;
  72.     NetWareUserInfo1: TNetWareUserInfo;
  73.     BDEUserInfo1: TBDEUserInfo;
  74.     SplashScreen1: TSplashScreen;
  75.     IniFileLink1: TIniFileLink;
  76.     Button5: TButton;
  77.     LoginDialog1: TLoginDialog;
  78.     Button6: TButton;
  79.     WorkingMsg1: TWorkingMsg;
  80.     Button7: TButton;
  81.     ErrorDialog1: TErrorDialog;
  82.     Button8: TButton;
  83.     DebugControl1: TDebugControl;
  84.     FormRestorer1: TFormRestorer;
  85.     ReSizerPanel1: TReSizerPanel;
  86.     Memo2: TMemo;
  87.     Memo3: TMemo;
  88.     ReSizerPanel2: TReSizerPanel;
  89.     Label11: TLabel;
  90.     BitBox1: TBitBox;
  91.     Button10: TButton;
  92.     Invoice1: TInvoice;
  93.     Button9: TButton;
  94.     Edit5: TEdit;
  95.     Label12: TLabel;
  96.     Label13: TLabel;
  97.     Edit6: TEdit;
  98.     Label14: TLabel;
  99.     RadioGroup1: TRadioGroup;
  100.     Button11: TButton;
  101.     PropertyViewer1: TPropertyViewer;
  102.     Label15: TLabel;
  103.     CheckBox1: TCheckBox;
  104.     tPackAboutBox1: TtPackAboutBox;
  105.     procedure FormCreate(Sender: TObject);
  106.     procedure Edit1Change(Sender: TObject);
  107.     procedure SpeedButton1Click(Sender: TObject);
  108.     procedure BitBox1Change(Sender: TObject);
  109.     procedure Button1Click(Sender: TObject);
  110.     procedure Button2Click(Sender: TObject);
  111.     procedure Button3Click(Sender: TObject);
  112.     procedure Button4Click(Sender: TObject);
  113.     procedure Button5Click(Sender: TObject);
  114.     procedure Button6Click(Sender: TObject);
  115.     procedure Button7Click(Sender: TObject);
  116.     procedure Button8Click(Sender: TObject);
  117.     procedure Button10Click(Sender: TObject);
  118.     procedure Button9Click(Sender: TObject);
  119.     procedure RadioGroup1Click(Sender: TObject);
  120.     procedure Button11Click(Sender: TObject);
  121.     procedure CheckBox1Click(Sender: TObject);
  122.   private
  123.     { Private declarations }
  124.   public
  125.     { Public declarations }
  126.   end;
  127.  
  128. const
  129.   BoolString: array[False..True] of string[5] = ('FALSE','TRUE');
  130.  
  131. var
  132.   tPack2Form: TtPack2Form;
  133.  
  134. implementation
  135.  
  136. {$R *.DFM}
  137.  
  138. {-----------------------------------------------------------------------------------------}
  139. { FORM CODE                                                                               }
  140. {-----------------------------------------------------------------------------------------}
  141.  
  142. procedure TtPack2Form.FormCreate(Sender: TObject);
  143. var
  144.   i:longint;
  145. begin
  146.   with TabbedNoteBook1 do begin
  147.     PageIndex:= 0;
  148.     Font:=Self.Font;
  149.     end;
  150.   CheckBox1.Checked:= DebugControl1.Enabled;
  151.  
  152.   with NovellGrid do begin
  153.     ColCount:=2;
  154.     ColWidths[0]:=120;
  155.     ColWidths[1]:=200;
  156.     Width:=320+GridLineWidth;
  157.     RowCount:=1+6;
  158.     Height:=RowCount*(DefaultRowHeight+GridLineWidth)+GridLineWidth;
  159.     cells[0,0]:='Property';
  160.     cells[1,0]:='Value';
  161.  
  162.     cells[0,1]:='ConnectID';
  163.     cells[0,2]:='ConnectNumber';
  164.     cells[0,3]:='ServerName';
  165.     cells[0,4]:='LoginName';
  166.     cells[0,5]:='FullName';
  167.     cells[0,6]:='LoginTime';
  168.  
  169.     with NetWareUserInfo1 do begin
  170.       cells[1,1]:=inttostr(ConnectID);
  171.       cells[1,2]:=inttostr(ConnectNumber);
  172.       cells[1,3]:=ServerName;
  173.       cells[1,4]:=LoginName;
  174.       cells[1,5]:=FullName;
  175.       cells[1,6]:=LoginTime +' (FORMAT??)';
  176.       end;
  177.     end;
  178.  
  179.   with WindowsGrid do begin
  180.     ColCount:=2;
  181.     ColWidths[0]:=120;
  182.     ColWidths[1]:=200;
  183.     Width:=320+GridLineWidth;
  184.     RowCount:=1+4;
  185.     Height:=RowCount*(DefaultRowHeight+GridLineWidth)+GridLineWidth;
  186.     cells[0,0]:='Property';
  187.     cells[1,0]:='Value';
  188.     cells[0,1]:='LoginName';
  189.     cells[0,2]:='CompanyName';
  190.     cells[0,3]:='WindowsPath';
  191.     cells[0,4]:='SaverDelay';
  192.  
  193.     with WindowsUserInfo1 do begin
  194.       cells[1,1]:=UserName;
  195.       cells[1,2]:=CompanyName;
  196.       cells[1,3]:=WindowsPath;
  197.       cells[1,4]:=inttostr(SaverDelay);
  198.       end;
  199.     end;
  200.  
  201.   with BDEGrid do begin
  202.     ColCount:=2;
  203.     ColWidths[0]:=120;
  204.     ColWidths[1]:=200;
  205.     Width:=320+GridLineWidth;
  206.     RowCount:=1+6;
  207.     Height:=RowCount*(DefaultRowHeight+GridLineWidth)+GridLineWidth;
  208.     cells[0,0]:='Property';
  209.     cells[1,0]:='Value';
  210.     cells[0,1]:='UserName';
  211.     cells[0,2]:='NetType';
  212.     cells[0,3]:='NetProtocol';
  213.     cells[0,4]:='NetShare';
  214.     cells[0,5]:='LocalShare';
  215.     cells[0,6]:='IniFile';
  216.     cells[0,7]:='LangDriver';
  217.  
  218.     with BDEUserInfo1 do begin
  219.       cells[1,1]:=UserName;
  220.       cells[1,2]:=NetType;
  221.       cells[1,3]:=inttostr(NetProtocol);
  222.       cells[1,4]:=BoolString[NetShare];
  223.       cells[1,5]:=BoolString[LocalShare];
  224.       cells[1,6]:=IniFile;
  225.       cells[1,7]:=LangDriver;
  226.       end;
  227.     end;
  228.  
  229.   Edit1.Text:=inttostr(BitBox1.Numeric);
  230.  
  231.   Edit2.Text:=Application.Title;
  232.   Edit3.Text:='Caption';
  233.   Edit4.Text:=Caption;
  234.   Button3.Click; {to save}
  235.  
  236. end;
  237.  
  238.  
  239. procedure TtPack2Form.SpeedButton1Click(Sender: TObject);
  240. begin
  241.   Close;
  242. end;
  243.  
  244. procedure TtPack2Form.BitBox1Change(Sender: TObject);
  245. begin
  246.   Edit1.Text:=inttostr(BitBox1.Numeric);
  247. end;
  248.  
  249. procedure TtPack2Form.Edit1Change(Sender: TObject);
  250. begin
  251.   BitBox1.Numeric:=StrToIntDef(Edit1.Text,0);
  252. end;
  253.  
  254.  
  255. procedure TtPack2Form.Button1Click(Sender: TObject);
  256. begin
  257.   Splashscreen1.Execute; {uses (customizable) component residing on form}
  258. end;
  259.  
  260. procedure TtPack2Form.Button2Click(Sender: TObject);
  261. begin
  262.   with TSplashScreen.Create(nil) do {NIL! fires.}
  263.     free; {instantiates and releases form loader}
  264. end;
  265.  
  266. procedure TtPack2Form.Button3Click(Sender: TObject);
  267. begin
  268.   with IniFileLink1 do begin {name/path blank by default point to exe dir/name}
  269.     Section:=Edit2.Text;
  270.     Entry:=Edit3.Text;
  271.     StringValue:=Edit4.Text; {this writes it as a string}
  272.     end;
  273. end;
  274.  
  275. procedure TtPack2Form.Button4Click(Sender: TObject);
  276. begin
  277.   with IniFileLink1 do begin {name/path blank by default point to exe dir/name}
  278.     Section:=Edit2.Text; {you don't have to do this usually. this is a demo}
  279.     Entry:=Edit3.Text;
  280.     Edit4.Text:=StringValue; {this reads it as a string}
  281.     end;
  282. end;
  283.  
  284. procedure TtPack2Form.Button5Click(Sender: TObject);
  285. begin
  286.   AboutBox;   {uses code in toolproc to run about box.
  287.                consider moving the code below into there as well.}
  288. end;
  289.  
  290. procedure TtPack2Form.Button6Click(Sender: TObject);
  291. begin
  292.   with LoginDialog1 do begin
  293.     Execute;
  294.     if not PassWordOk then
  295.       raise Exception.Create('PASSWORD NOT SUPPLIED.. TRY ''TPACK''');
  296.     end;
  297.  
  298. end;
  299.  
  300. procedure TtPack2Form.Button7Click(Sender: TObject);
  301. const
  302.   i:longint=0;
  303. begin
  304.   WorkingMsg1.Execute;
  305.   while WorkingMsg1.Active do begin
  306.     inc(i);
  307.     Application.Hint:='Sample Process running; '+inttostr(i);
  308.     Application.OnHint(Sender);
  309.     end;
  310. end;
  311.  
  312. procedure TtPack2Form.Button8Click(Sender: TObject);
  313. begin
  314.   ErrorDialog1.Test:=true;
  315. end;
  316.  
  317. procedure TtPack2Form.Button10Click(Sender: TObject);
  318. begin
  319.   Invoice1.Execute;
  320. end;
  321.  
  322. procedure TtPack2Form.Button9Click(Sender: TObject);
  323. begin
  324.   PropertyViewer1.Persistent:=tPack2Form;
  325.   PropertyViewer1.Execute;
  326. end;
  327.  
  328. procedure TtPack2Form.RadioGroup1Click(Sender: TObject);
  329. begin
  330.   with TRadioGroup(Sender) do
  331.     case ItemIndex of
  332.      -1: exit;
  333.       0: begin
  334.          Edit5.Text:='dir';
  335.          Edit6.Text:='/p';
  336.          end;
  337.       1: begin
  338.          Edit5.Text:='notepad';
  339.          Edit6.Text:='!readme';
  340.          end;
  341.       2: begin
  342.          Edit5.Text:='tpDll';
  343.          Edit6.Text:='AboutBox';
  344.          end;
  345.     end;
  346. end;
  347.  
  348. procedure TtPack2Form.Button11Click(Sender: TObject);
  349. var
  350.   s:TGenericShell;
  351. begin
  352.   with RadioGroup1 do
  353.     case ItemIndex of
  354.      -1: exit;
  355.       0: s:=TDosShell.Create(Owner);
  356.       1: s:=TWindowsShell.Create(Owner);
  357.       2: s:=TDLLShell.Create(Owner);
  358.       end;
  359.   with s do try
  360.     Flags:=Flags+[shlMsgTillReady];
  361.     run(edit5.Text,edit6.Text);
  362.   finally
  363.     free;
  364.     end;
  365. end;
  366.  
  367. procedure TtPack2Form.CheckBox1Click(Sender: TObject);
  368. begin
  369.   DebugControl1.Enabled:= CheckBox1.Checked;
  370. end;
  371.  
  372. end.
  373.